import React, { useState } from 'react';
// import store from '../redux/store';
import {useNavigate} from 'react-router-dom';
import { connect } from 'react-redux';
function City(props){
    const navigate = useNavigate()
    const [list]=useState(['北京','上海','广州','深圳','南昌'])
    return (
        <div>
            City
            <ol>
                {
                    list.map(item=><li key={item} onClick={()=>{
                        // store.dispatch({    //通知
                        //     type:"change-city",
                        //     citys:item,
                        //     isShow:false
                        // })
                        props.changecity(item)
                        //通知完了跳转回去
                        navigate("/cinemas")
                    }}>{item}</li>)
                }
            </ol>
        </div>
    );
}

export default connect(null,{
    changecity(item){
        return{
            type:"change-city",
            citys:item,
            isShow:false
        }
    }
})(City)